﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace SGCG.Model
{
    public abstract class BorderedGraphicObject : GraphicObject, IHasBorder
    {

        public BorderedGraphicObject(GraphicObject parent) : base(parent) { }

        public int DashSize 
        {
            get 
            { 
                return 12; 
            } 
        }

        public int DashInterspace 
        {
            get
            {
                return 6 + (LineThickness == LineThickness.Dupla ? 2 : 0); 
            }
        }

        public int DotInterspace
        {
            get
            {
                return 1 + (LineThickness == LineThickness.Dupla ? 1 : 0);
            }
        }

        private Color color;
        public Color Color
        {
            get
            {
                if (this.Selected)
                {
                    if (color == Colors.Magenta)
                        return Colors.Purple;
                    else
                        return Colors.Magenta;
                }
                else
                {
                    return color;
                }
            }
            set
            {
                if (color != value)
                {
                    color = value;
                    RaiseGraphicPropertyChanged("Color");
                }
            }
        }

        public Color OriginalColor { get { return color; } }

        private LineThickness lineThickness;
        public LineThickness LineThickness
        {
            get { return lineThickness; }
            set
            {
                if (lineThickness != value)
                {
                    lineThickness = value;
                    RaiseGraphicPropertyChanged("LineThickness");
                }
            }
        }

        private LineStyle lineStyle;
        public LineStyle LineStyle
        {
            get { return lineStyle; }
            set
            {
                if (lineStyle != value)
                {
                    lineStyle = value;
                    RaiseGraphicPropertyChanged("LineStyle");
                }
            }
        }

        protected void CopyProperties(BorderedGraphicObject other)
        {
            base.CopyProperties(other);
            other.LineStyle = LineStyle;
            other.LineThickness = LineThickness;
            other.Color = OriginalColor;
        }

    }
}
